package org.czp.message;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;

public class MessageQuue {

	private static final MessageQuue INSTANCE = new MessageQuue();

	private BlockingQueue<String> textMsgs;
	private BlockingQueue<byte[]> binMsgs;

	private MessageQuue() {
		textMsgs = new LinkedBlockingQueue<String>();
		binMsgs = new LinkedBlockingQueue<byte[]>();
	}

	public static MessageQuue getInstance() {
		return INSTANCE;
	}

	public void pushToQueue(String obj) {
		textMsgs.add(obj);
	}

	public void pushToQueue(byte[] obj) {
		binMsgs.add(obj);
	}

	public String getTextMessage() throws InterruptedException {
		return textMsgs.take();
	}

	public byte[] getObjMessage() throws InterruptedException {
		return binMsgs.take();
	}
}
